package com.bingo.demo.service;

import com.bingo.demo.DAO.AlbumMapper;
import com.bingo.demo.pojo.Album;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class AlbumService {

    @Autowired
    AlbumMapper albumMapper;

    public void addAlbum(Album album){
        //获取系统时间
        Date date = new Date();
        Timestamp ts=new Timestamp(date.getTime());
        album.setPublishTime(ts);
        albumMapper.addAlbum(album);
    }

    public Album findById(Integer id){
        return albumMapper.findById(id);
    }

    public List<Album> findByUserId(Integer userId){
        return albumMapper.findByUserId(userId);
    }

    public void deleteByAlbumId(Integer id){
        albumMapper.deleteById(id);
    }
}
